package com.ofcoder.algorithmsamples.seata.starter;

import com.ofcoder.algorithmsamples.seata.ApplicationKeeper;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @author: lyy
 * created in 2021/5/27
 */
public class StorageStarter {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext accountContext = new ClassPathXmlApplicationContext(new String[]{"spring/dubbo-storage-service.xml"});
        accountContext.getBean("storageService");
        JdbcTemplate storageJdbcTemplate = (JdbcTemplate) accountContext.getBean("jdbcTemplate");
        storageJdbcTemplate.update("delete from seata_storage where commodity_code = 'C00321'");
        storageJdbcTemplate.update("insert into seata_storage(commodity_code, count) values ('C00321', 100)");

        new ApplicationKeeper(accountContext).keep();
    }

}
